package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Respond;
import cn.wolfcode.trip.base.query.RespondQueryObject;
import cn.wolfcode.trip.base.service.IRespondService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 解答问题控制器
 */
@RestController
@RequestMapping("respond")
public class RespondController {

    @Autowired
    private IRespondService respondService;

    /**
     * 添加解答信息
     * @param respond
     * @return
     */
    @PostMapping
    public JSONResult insertRespond (Respond respond){
        respondService.insertRespond(respond);
        return new JSONResult();
    }

    /**
     * 根据问题id查询所有的解答信息
     * @param qo
     * @return
     */
    @GetMapping("{questionId}")
    public PageInfo getRespondById(RespondQueryObject qo){
        PageInfo respond= respondService.selectRespondById(qo);
        return respond;
    }
}
